<%--
 
  User: Jackyin
  Date: 2011-1-24
  Time: 15:47:52
  To change this template use File | Settings | File Templates.
--%>

<%@ include file="/inc/SessionTimeout.inc" %>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page import="com.oval.util.*" %>

<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<%
    Category cat = Category.getInstance("jsp.EmployeeAreaMap");
    String strTableName = "v_zylemployeeareamapummary";
    String strModuleName = "COM";
    String privilegeCode = "10213";
%>

<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>

<%int LangNums = ConstantProp.multiLangNumber;%>

<html>
<head>
    <title>EmployeeareaMap</title>
    <PageFlow:CheckPageFlow pageName="p_zylemployeeareasummary"/>
    <%@ include file="/inc/SumDiv.inc" %>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" href="../../css/<%= strLanguageCode %>/main.css" type="text/css">
    <script language="JavaScript" src="../css/<%= strLanguageCode %>/script.js"></script>
    <script language="JavaScript" src="../../js/ScriptLib.js"></script>
    <script language="JavaScript" src="../../js/SummaryDivision.js"></script>
    <script type="text/javascript">
        var index = 0;
        function mathindex(com){
            if(com.checked){
            	index++;
            }else{
            	index--;
            }
        }
        
        
        
        function page_add() {
            if (!checkALLElems(document.getElementById("newdetail"))) return;
            cform.actionname.value = "add";
            cform.target = "_self";
            isRunning = true;
            cform.submit();
        }

        function page_save() {
            if (!checkALLElems(document.getElementById("olddetail"))) return;
            cform.actionname.value = "save";
            cform.target = "_self";
            isRunning = true;
            cform.submit();
        }

        function page_delete() {
        if(index <= 0) {
           alert("<%= message.getMessageDesc("MUST_SELECT_ONE_RECORD") %>");
           return;
        }
        var flag = confirm("<%= message.getMessageDesc("ARE_YOU_SURE_DEL") %>");
  				if(!flag)
    			return;
            cform.actionname.value = "delete";
            cform.target = "_self";
            isRunning = true;
            cform.submit();
        }
        
    function page_selectEmployee(num){
	
		if(popwindow!=null)
	    popwindow.close();
		popwindow = window.open('EmployeeAllWindow.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode%>&num='+num,'newwindow', 'height=350, width=850,top=150,left=300,toolbar=n0, menubar=no, scrollbars=no, resizable=no, location=no,status=no');
     
		}

    function page_selectArea(num){
    	
		if(popwindow!=null)
	    popwindow.close();
		popwindow = window.open('AreaAllWindow.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode%>&num='+num,'newwindow', 'height=350, width=850,top=150,left=300,toolbar=n0, menubar=no, scrollbars=no, resizable=no, location=no,status=no');
     
		}
	
	function setNewEmployeeCode(ids,names,codes,deptid,num){
		
	if(num!=-1){
		var employeename = eval("document.cform.employeename"+num);
		var employeecode = eval("document.cform.employeecode"+num);
		var employeeid = eval("document.cform.employeeid"+num);
		var deptid = eval("document.cform.deptid"+num);
		employeename.value=names;
		employeecode.value=codes;
		employeeid.value=ids;
		deptid.value=deptid;
		}else{
		document.cform.employeename.value=names;
		document.cform.employeecode.value=codes;
		document.cform.employeeid.value=ids;
		document.cform.deptid.value=deptid;
		}
	}


	function setNewAreaCode(ids,names,codes,parentid,num){
	if(num!=-2){
		var businessareaname = eval("document.cform.areaname"+num);
		var businessareacode = eval("document.cform.areacode"+num);
		var businessareaid = eval("document.cform.areaid"+num);
		var parentareaid = eval("document.cform.parentid"+num);
		businessareaname.value=names;
		businessareacode.value=codes;
		businessareaid.value=ids;
		parentareaid.value=parentid;
		}else{
		document.cform.businessareaname.value=names;
		document.cform.businessareacode.value=codes;
		document.cform.businessareaid.value=ids;
		document.cform.parentareaid.value=parentid;
		}
	}
	
	
	function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(cform,actionvalue,orderbyname);
  editform.action = "EmployeeAreaMap.jsp?<%= OvalTools.randomURL() %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();
}
	
    </script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form name="cform" method="post" action="../../Dispatcher">
    <custom:hidden property="actionname" value="save"/>
    <custom:hidden property="pagename" value="p_zylemployeeareasummary"/>
    <%@include file="/inc/PageLocation.inc" %>
    <table width="1000" border="0" cellspacing="0">
 <!-- 
 
  <tr>
    <td>
      <table width="1000" border="0" cellspacing="0">
        <tr>
          <td class="summary_top" colspan="2" ></td>
        </tr>
      <%@ include file="/inc/SummarySearch.inc" %>
      </table>
    </td>
  </tr>
  -->
        <tr>
            <td class="b">
                <div align="center"><font size="3"><br><%= label.getLabelName("L_EmployeeAreaMap")%><br></font>
                </div>
            </td>
        </tr>
        <tr>
            <td>
                <table width="800" cellspacing="0" cellpadding="0" border="0">
                    <tr>
                        <td>
                            <table width="1000" border="1" cellpadding="0" bordercolorlight="#999999"
                                   bordercolordark="#FFFFFF"
                                   cellspacing="0" align="center">
                                <tr class="deepblue-left">
                                    <td class="title_center">&nbsp;</td>
                      				<td class="title_center"><%=label.getLabelName("L_Employee")%>
                                    </td>
                                    <td class="title_center"><%=label.getLabelName("L_Region")%>
                                    </td>
                                </tr>
                    <span id="olddetail">
                    <%
                        Vector employeeareamap = (Vector) pageContext.getAttribute("employeeareamap");
                        if (employeeareamap == null)
                        	employeeareamap = new Vector();
                    %>
                    <input type="hidden" name="numrows" value="<%=employeeareamap.size()%>"/>
                    <logic:iterate id="map" collection="<%=employeeareamap %>" indexId="employeeareamapid">
 
                    <tr>
                       <td>
                                <custom:checkbox name="map" property="employeeareamapid" changedName="mappingid" style="border:none" onchange="javascript:mathindex(this);"/>
                            </td>
                      <td>
                        <custom:text name="map" property="employeecode" colIndex="<%=employeeareamapid%>" style="width:100px;" readonly="true" />
                          <a  onclick="page_selectEmployee(<%=employeeareamapid%>)"><input type="button" class="button3" value="*"></a>
                        <custom:text name="map" property="employeename" colIndex="<%=employeeareamapid%>" style="width:140px;" readonly="true"/>
                        <custom:hidden  name="map" property="employeeid" colIndex="<%=employeeareamapid%>"></custom:hidden>
                          <custom:hidden  name="map" property="deptid" colIndex="<%=employeeareamapid%>"></custom:hidden>
                       </td>
                            <td>
                         <custom:text name="map" property="businessareacode" colIndex="<%=employeeareamapid%>" style="width:100px;" readonly="true" />
                          <a  onclick="page_selectArea(<%=employeeareamapid%>)"><input type="button" class="button3" value="*"></a>
                        <custom:text name="map" property="businessareaname" colIndex="<%=employeeareamapid%>" style="width:140px;" readonly="true"/>
                        <custom:hidden  name="map" property="businessareaid" colIndex="<%=employeeareamapid%>"></custom:hidden>
                          <custom:hidden  name="map" property="parentareaid" colIndex="<%=employeeareamapid%>"></custom:hidden>
                             <custom:hidden name="map" property="employeeareamapid" colIndex="<%=employeeareamapid%>"/>
                            </td>
                        </tr>
                    </logic:iterate>
                        </span>
                    <span id="newdetail">
                 
                    <tr>
                        <td>&nbsp;</td>
                        <td>
                        <custom:text name="newdata" property="employeecode" style="width:100px;" readonly="true"/>
                        <a  onclick="page_selectEmployee(-1)"><input type="button" class="button3" value="*"></a>
                        <custom:text name="newdata" property="employeename" style="width:140px;" readonly="true"/>
                        <custom:hidden  name="newdata" property="employeeid"></custom:hidden>
                         <custom:hidden  name="newdata" property="deptid"></custom:hidden>
                       </td>
                        <td>
                           <custom:text name="newdata" property="businessareacode"  style="width:100px;" readonly="true"/>
                        <a  onclick="page_selectArea(-2)"><input type="button" class="button3" value="*"></a>
                        <custom:text name="newdata" property="businessareaname"  style="width:140px;" readonly="true"/>
                        <custom:hidden  name="newdata"  property="businessareaid"></custom:hidden>
                         <custom:hidden  name="newdata"  property="parentareaid"></custom:hidden>
                         
                      </td>
                    </tr>
                        </span>
                            </table>
                           <%@ include file="/inc/SummaryAction.inc" %>
                        </td>
                    </tr>
      
                    <tr>
                        <td height="49" class="title_center">
                            <a onclick="page_add();">
                                <custom:button type="1"
                                               label="L_Add"
                                               imgsrc="back.gif"
                                               border="0" privilegeCode="10213"
                                               style="width:60"/></a>
                            &nbsp;&nbsp;
                            <a onclick="page_save();">
                                <custom:button type="1" label="L_Save"
                                               imgsrc="back.gif" border="0" privilegeCode="10213"
                                               style="width:60"/></a>
                            &nbsp;&nbsp;
                            <a onclick="page_delete();">
                                <custom:button type="1" label="L_Delete"
                                               imgsrc="back.gif" border="0" privilegeCode="10213"
                                               style="width:60"/></a>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</form>
</body>
</html>






